package com.madou.dbtool.redis.panel.ui.types;

import com.madou.common.annotation.HideClass;
import com.madou.dbtool.redis.manager.RedisSourceManager;

import javax.swing.*;

/**
 * 类型预览面板创建工厂
 * @author miukoo
 */
@HideClass
public class TypePanelFactory {

    public static JComponent createTypePanel(String type, String selectKey, RedisSourceManager redisSourceManager,int dbIndex) throws Exception {
        if("string".equalsIgnoreCase(type)){
            return new StringTypePanel(redisSourceManager,selectKey,dbIndex);
        }
        if("hash".equalsIgnoreCase(type)){
            return new HashTypePanel(redisSourceManager,selectKey,dbIndex);
        }
        if("list".equalsIgnoreCase(type)){
            return new ListTypePanel(redisSourceManager,selectKey,dbIndex);
        }
        if("set".equalsIgnoreCase(type)){
            return new SetTypePanel(redisSourceManager,selectKey,dbIndex);
        }
        if("zset".equalsIgnoreCase(type)){
            return new ZSetTypePanel(redisSourceManager,selectKey,dbIndex);
        }
        return null;
    }

}
